package com.woniuxy.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.woniuxy.dao.ExpireRemindMapper;
import com.woniuxy.pojo.ExpireRemind;
import com.woniuxy.service.ExpireRemindService;
import com.woniuxy.util.DataGridView;
import com.woniuxy.vo.ExpireRemindVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
public class ExpireRemindServiceImpl implements ExpireRemindService {
    @Autowired
    ExpireRemindMapper expireRemindMapper;

    @Override
    public DataGridView findByPage(ExpireRemindVo expireRemindVo) {
        Page<Object> page= PageHelper.startPage(expireRemindVo.getPage(),expireRemindVo.getLimit());
        List<ExpireRemind> maintain = expireRemindMapper.selectMaintain(expireRemindVo);
        List<ExpireRemind> inspection = expireRemindMapper.selectInspection(expireRemindVo);
        List<ExpireRemind> insurance = expireRemindMapper.selectInsurance(expireRemindVo);
        List<ExpireRemind> list = new ArrayList<>();
        list.addAll(maintain);
        list.addAll(inspection);
        list.addAll(insurance);
        return new DataGridView(page.getTotal(),list);
    }
}
